package org.test.ping.controller

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import spock.lang.Specification

@SpringBootTest
@AutoConfigureMockMvc
class PingControllerTest extends Specification{

    @Autowired
    private MockMvc mockMvc;

    def "test ping controller"(){
        given:
        String[] fileNames = "ping.json"
        when:
        for (int i=0;i<10;i++)
        {
            try {
                mockMvc.perform(MockMvcRequestBuilders.get("/ping").param("fileNames",fileNames) )
            }catch (Exception e)
            {
                println("error: "+e.getMessage())
            }
        }
        then:
        println("done")
    }

}
